-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Week 1 #1
base: master
Are you sure you want to change the base?
Week 1 #1
Conversation
(facts "should return the odd numbers" | ||
(odd-numbers #{1 2 3 4 5}) => '(1 3 5)) | ||
|
||
(defn palindrome [col] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, a simpler solution exists, it's enough to compare the original sequence to its reversed version
(loop [result 1 | ||
index 1] | ||
(if (= index n) | ||
(* result index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not optimal: you have *
in two places. Try running index from n down to 1.
Also, try running it with big numbers - it causes integer overflow. Use *'
instead of *
No description provided.